{% extends "base.html" %}

{% block head_title %}
{%- if profileView -%}
  @{{ profileView.Handle }} on Bluesky
{%- else -%}
  Bluesky
{%- endif -%}
{% endblock %}

{% block html_head_extra -%}
  <meta property="og:site_name" content="Bluesky Social">
  <meta property="og:type" content="profile">
{%- if requestURI %}
  <meta property="og:url" content="{{ requestURI }}">
  <link rel="canonical" href="{{ requestURI|canonicalize_url }}" />
{% endif -%}

{%- if profileView -%}
  <meta property="profile:username" content="{{ profileView.Handle }}">
  {%- if profileView.DisplayName %}
  <meta property="og:title" content="{{ profileView.DisplayName }} (@{{ profileView.Handle }})">
  {% else %}
  <meta property="og:title" content="{{ profileView.Handle }}">
  {% endif -%}

  <link rel="alternate" href="at://{{ profileView.Did }}/app.bsky.actor.profile/self" />

  <meta name="twitter:label1" content="Account DID">
  <meta name="twitter:value1" content="{{ profileView.Did }}">

  {%- if requestHost %}
  <link rel="alternate" type="application/rss+xml" href="https://{{ requestHost }}/profile/{{ profileView.Did }}/rss">
  {% endif %}

  {# Only show details if auth isn't required #}
  {% if not requiresAuth %}
    {%- if profileView.Description %}
    <meta name="description" content="{{ profileView.Description }}">
    <meta property="og:description" content="{{ profileView.Description }}">
    {% endif -%}
    {%- if profileView.Banner %}
    <meta property="og:image" content="{{ profileView.Banner }}">
    <meta name="twitter:card" content="summary_large_image">
    {%- elif profileView.Avatar -%}
    {# Don't use avatar image in cards; usually looks bad #}
    <meta name="twitter:card" content="summary">
    {% endif %}
  {% else %}
    <meta name="description" content="This profile requires authentication to view.">
    <meta property="og:description" content="This profile requires authentication to view.">
    <meta property="twitter:description" content="This profile requires authentication to view.">
  {% endif %}
  
  <script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "ProfilePage",
    "dateCreated": "{{ profileView.CreatedAt }}",
    "mainEntity": {
      "@type": "Person",
      {%- if profileView.DisplayName %}
      "name": "{{ profileView.DisplayName }}",
      "alternateName": "@{{ profileView.Handle }}",
      {% else %}
      "name": "@{{ profileView.Handle }}",
      {% endif -%}
      "identifier": "{{ profileView.Did }}",
      "description": "{{ profileView.Description }}",
      "image": "{{ profileView.Avatar }}",
      "interactionStatistic": [
        {
          "@type": "InteractionCounter",
          "interactionType": "https://schema.org/FollowAction",
          "userInteractionCount": {{ profileView.FollowersCount }}
        }
      ],
      "agentInteractionStatistic": [
        {
          "@type": "InteractionCounter",
          "interactionType": "https://schema.org/FollowAction",
          "userInteractionCount": {{ profileView.FollowsCount }}
        },
        {
          "@type": "InteractionCounter",
          "interactionType": "https://schema.org/WriteAction",
          "userInteractionCount": {{ profileView.PostsCount }}
        }
      ]
    }
  }
  </script>
{% endif -%}
{%- endblock %}

{% block noscript_extra -%}
{%- if profileView -%}
<div id="bsky_profile_summary">
  <h3>Profile</h3>
  <p id="bsky_display_name">{{ profileView.DisplayName }}</p>
  <p id="bsky_handle">{{ profileView.Handle }}</p>
  <p id="bsky_did">{{ profileView.Did }}</p>
  <p id="bsky_profile_description">{{ profileView.Description }}</p>
</div>
{% endif -%}
{%- endblock %}
